package bird.array;

/**
 * @author sijunqiang
 * @data 2021/5/18 23:31
 * @description: 数组的简单的增 删 改 查。
 */
public class Main {

    public static void main(String[] args) {

        //Test add element to array
        Array<Integer> array = new Array<Integer>(20);
        for (int i = 0; i < 10; i++) {
            array.addLast(i);
        }
        System.out.println("array = " + array);

        // Test addFirst
        array.addFirst(666);
        System.out.println("array = " + array);

        //Test  insert element in appoint index
        array.add(5, 777);
        System.out.println("array = " + array);

        // Test get element to array
        Integer i = array.get(0);
        System.out.println(array + " " + i);

        // Test set newElement to array index
        Integer ret = array.set(2, 9999);
        System.out.println(array + "" + ret);

        // Test find element in array
        Integer i1 = array.find(94999);
        System.out.println(i1);

        //Test contains
        Boolean contains = array.contains(9999);
        System.out.println("contains = " + contains);

        // Test remove first element
        Integer first = array.removeFirst();
        System.out.println(array);

        // Test remove last element
        Integer last = array.removeLast();
        System.out.println(array);

        // Test remove any element
        Boolean aBoolean = array.removeElement(777);
        System.out.println("aBoolean = " + aBoolean);
        System.out.println(array);
    }
}
